import pandas as pd
import matplotlib.pyplot as plt

# 读取CSV文件
data = pd.read_csv('bilibili_videos.csv')

# 假设 '视频描述' 列中包含了 float 类型数据，我们先将其转换为字符串类型
data['视频描述'] = data['视频描述'].astype(str)

# 对 '视频描述' 列进行分词并计算长度
desc_lengths = data['视频描述'].str.split().apply(len)

# 统计数据
coin_sum = data['投币数'].sum()
danmaku_sum = data['弹幕数'].sum()
favorite_sum = data['收藏数'].sum()
like_sum = data['喜欢数'].sum()
view_sum = data['观看数'].sum()
share_sum = data['分享数'].sum()

# 视频分区占比
category_counts = data['视频分类'].value_counts()
plt.rcParams['font.sans-serif']=['SimHei']
plt.figure(figsize=(8, 8))
plt.pie(category_counts, labels=category_counts.index, autopct='%1.1f%%')
plt.title('Bilibili 视频分区占比')
plt.show()

